package com.tony.pmp.server.controller;

import com.google.common.collect.Maps;
import com.tony.pmp.common.response.BaseResponse;
import com.tony.pmp.common.response.StatusCode;
import com.tony.pmp.common.utils.PageUtil;
import com.tony.pmp.server.service.SysProductListService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 *
 * @Title: SysProductListController
 * @Auther: 皮蛋布丁
 * @Date: 2021/08/10/16:48
 * @Description: 商品
 */
@RestController
@RequestMapping("sys/product")
public class SysProductListController extends AbstractController{

    @Autowired
    private SysProductListService sysProductListService;

    /**
    * @Description: list 获取商品列表数据(分页,模糊查询)
    * @Param: []
    * @return: com.tony.pmp.common.response.BaseResponse
    * @Author: 皮蛋布丁
    * @Date: 2021/8/10 16:51
    */
    @RequestMapping("/list")
    @RequiresPermissions("sys:product:list")
    public BaseResponse list(@RequestParam Map<String,Object> paramMap) {
        BaseResponse response = new BaseResponse(StatusCode.Success);
        Map<String,Object> resMap = Maps.newHashMap();
        try {
            log.info(">>>>>>获取商品列表数据>>>>>>");
            PageUtil page = sysProductListService.queryPage(paramMap);
            resMap.put("page",page);
        } catch (Exception e) {
            response = new BaseResponse(StatusCode.Fail.getCode(),e.getMessage());
        }
        response.setData(resMap);
        return response;
    }


}
